let loadShopURL=`http://jx.xuzhixiang.top/ap/api/allproductlist.php`
axios.get(loadShopURL,{params:{
    pagesize:50,pagenum:0,uid:109742,
}}).then(function(resolve){
    let shop=resolve.data.data;
    console.log(shop);
    shop.forEach((v,i)=>{
        switch (v.pprice) {
            case '1.00':
                loadlist('recommend',v)
            break;
            case '2.00':
                loadlist('handpick',v)
            break;
            case '3.00':
                loadlist('popular',v)
            break;
            case '4.00':
                loadlist('gift',v)
            break;
            default:
                break;
        }
    });
}).catch(function(reject){
    console.log(reject);
})

let alltype=['礼包','大型多人角色扮演游戏','卡牌包','策略类卡牌游戏','团队动作游戏','即时策略游戏','多人在线战术策略游戏','可解锁内容','角色动作扮演游戏','游戏升级包','游戏服务','动作角色扮演游戏','游戏时间','仅限狂野模式','虚拟坐骑','指挥官']
// 计数，每五个添加class消除右边距
let times=[0,0,0,0]
function loadlist(type,key){
    let desc=key.pdesc.split('/')
    let hightlight=''
    let hightlighttrueorfalse=alltype.every((v,i)=>v!=desc[1])
    let tag=''
    if(hightlighttrueorfalse){
        hightlight=`<p class="hightlight">${desc[1]}</p>`
        tag=`<p class="type">${desc[2]}</p>`
    }else{
        tag=`<p class="type">${desc[1]}</p>`
    }
    let spanPrice=``
    switch (desc.length) {
        case 3:
            if (/奥术宝珠/.test(desc[2])) {
                spanPrice=`<div><span class="nomoney"><img src="images/shop/test_price.png" alt="">${desc[2]}</span></div></div></div>`
            }else{
                spanPrice=`<div><span class="no_payoffPrice">${desc[2]}</span></div></div></div>`
            }
        break;
        case 4:
            spanPrice=`<div><span class="no_payoffPrice">${desc[3]}</span></div></div></div>`
        break;
        case 6:
            spanPrice=`<div><span class="payprice">${desc[3]}</span><span class="price">${desc[4]}</span><span class="payoff">${desc[5]}</span></div></div></div>`
        break;
        default:
        break;
    }
    // 分类型判断计数
    let right=false;
    if(type=='recommend'){
        ++times[0];
        right=times[0]%5?true:false;
    }else if (type=='handpick') {
        ++times[1];
        right=times[1]%5?true:false;
    }else if (type=='popular') {
        ++times[2];
        right=times[2]%5?true:false;
    }else if (type=='gift') {
        ++times[3];
        right=times[3]%5?true:false;
    }
    let goods=''
    let PICSRC=''
    switch (key.pname) {
        case '暗黑破坏神III':
            PICSRC ="../images/gameicon/diablo-iii.svg"
        break;
        case '守望先锋':
            PICSRC="../images/gameicon/overwatch.svg"
        break;
        case '风暴英雄':
            PICSRC="../images/gameicon/heroes-of-the-storm.svg"
        break;
        case '星际争霸II':
            PICSRC="../images/gameicon/starcraft-ii.svg"
        break;
        case '炉石传说':
            PICSRC="../images/gameicon/hearthstone.svg"
        break;
        case '魔兽世界':
            PICSRC="../images/gameicon/world-of-warcraft.svg"
        break;
        case '魔兽世界(经典怀旧服)':
            PICSRC="../images/gameicon/world-of-warcraft-classic.svg"
        break;
        default:
        break;
    }
    if(right){
        goods=`<div onclick='shopifo(${key.pid})'>
        <img src="${key.pimg}" alt="">
        <div>
            <p class="tag"><img src="${PICSRC}" alt="">${key.pname}</p>
            <p class="desc">${desc[0]}</p>`
    }else{
        goods=`<div class='noright' onclick='shopifo(${key.pid})'>
        <img src="${key.pimg}" alt="">
        <div>
            <p class="tag"><img src="images/gameicon/world-of-warcraft.svg" alt="">${key.pname}</p>
            <p class="desc">${desc[0]}</p>`
    }
    if(hightlight!=''){
        goods+=hightlight
    }
    goods+=`<p class="type">${tag}</p>`
    goods+=spanPrice
    // 判断分类
    if(type=='recommend'){
        document.querySelector('.recommend').innerHTML+=goods;
    }else if (type=='handpick') {
        document.querySelector('.handpick').innerHTML+=goods;
    }else if (type=='popular') {
        document.querySelector('.popular').innerHTML+=goods;
    }else if (type=='gift') {
        document.querySelector('.gift').innerHTML+=goods;
    }
}